﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

using QLTTAN.DTO;
namespace QLTTAN.DAL
{
    public class ThamSoDAL
    {
        ConnectionData conn;

        public DataTable ThamSo_Load()
        {
            conn = new ConnectionData();
            return conn.GetData("THAMSO_LOAD");
        }

        public int ThamSo_Update(List<ThamSoDTO> lstTH_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 2;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            try
            {
                foreach (ThamSoDTO TH_DTO in lstTH_DTO)
                {
                    name[0] = "TenThamSo";
                    value[0] = TH_DTO.TenThamSo;
                    name[1] = "GiaTri";
                    value[1] = TH_DTO.GiaTri;

                    conn.UpdateData("THAMSO_UPDATE", name, value, Nparameter);
                }
            }
            catch
            {
                return 0;
            }
            
            return 1;
        }
    }
}
